package com.atguigu.userprofile.dao

import com.atguigu.userprofile.bean.{TagInfo, TaskInfo}
import com.atguigu.userprofile.util.MySqlUtil

object TaskDAO {

  def getTaskInfo(taskId:String):  TaskInfo  ={
    val taskInfoSql: String =
      s"""select id,task_name,
         | task_status,task_comment,task_time ,
         | task_type,exec_type,main_class,file_id,
         | task_args,task_sql,task_exec_level,create_time
         | from task_info where id=$taskId""".stripMargin

    //或有对象   key->hashmap --> Option[value] ->1 Some[value] .get  -->2 None
    val taskInfoOpt: Option[TaskInfo] = MySqlUtil.queryOne(taskInfoSql,classOf[TaskInfo],true)
    if(taskInfoOpt==None){
      throw  new RuntimeException("error :  no task for this task_id:"+taskId)
    }else{
      taskInfoOpt.get
    }

  }

}
